package com.xquant.marketdata.marketdata.controller;

import com.github.pagehelper.PageInfo;
import com.xquant.common.security.utils.ExcelUtil;
import com.xquant.common.core.web.controller.BaseController;
import com.xquant.common.core.web.page.TableDataInfo;
import com.xquant.common.log.annotation.Log;
import com.xquant.common.log.enums.BusinessType;
import com.xquant.marketdata.curvestrip.domain.TirCurveDTO;
import com.xquant.marketdata.marketdata.service.TirCurveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * 利率曲线
 * newCloud
 *
 * @author ershuai.zhao
 */
@RestController
@RequestMapping("tirCurveController")
public class TirCurveController extends BaseController {

    @Autowired
    private TirCurveService tirCurveService;


    /**
     * 查询利率曲线行情
     */
    @ResponseBody
    @RequestMapping(value = "/queryTirCurvePriceByPage.action")
    @PreAuthorize("@ss.hasPermi('curve:ircurve:ircurvequota:list')")
    public TableDataInfo queryTirCurveInfoByPage(@RequestParam Map<String, Object> param) {
        startPage();
        return getDataTable(tirCurveService.queryTirCurvePriceByPage(param));
    }

    @Log(title = "利率行情信息", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('curve:ircurve:ircurvequota:export')")
    @PostMapping("/exportQuote")
    public void exportQuote(HttpServletResponse response, @RequestParam Map<String, Object> param) {
        startPage();
        List<TirCurveDTO> list = tirCurveService.queryTirCurvePriceByPage(param);
        ExcelUtil<TirCurveDTO> util = new ExcelUtil<TirCurveDTO>(TirCurveDTO.class);
        util.exportExcel(response, list, "利率行情信息");
    }

    /**
     * 查询利率曲线信息
     */
    @ResponseBody
    @RequestMapping(value = "/queryTirCurveInfoByPage.action")
    public PageInfo<Map> queryTirCurvePriceByPageByPage(@RequestParam Map<String, Object> param) {
        startPage();
        PageInfo<Map> pageInfo = tirCurveService.queryTirCurveInfoByPage(param);

        return pageInfo;
    }


}
